package com.lagou.dubbo.provider.service;

import com.lagou.dubbo.api.RpcTestService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@org.apache.dubbo.config.annotation.Service
public class RpcTestServiceImpl implements RpcTestService {
    @Override
    public String sayHello(String helloWord) {
        log.info("sayHello---->" + helloWord);

        String ip = RpcContext.getContext().getAttachment("ip");

        return "B_" + helloWord + ",ip=" + ip;
    }

    @Override
    public String methodA() {

        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "B_A";
    }

    @Override
    public String methodB() {

        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "B_B";
    }

    @Override
    public String methodC() {
        try {
            Thread.sleep(70);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "B_C";
    }
}
